{extend name="public:base"}
{block name='css'}
{/block}

{block name='body'}
<div class="view view-main white-navbar white-page white-toolbar">
    <div data-name="home" class="page">


        <div class="navbar">
            <div class="navbar-inner">
                <!-- <div class="left"><a href="{$my_prev_url|default='/'}" class="external"><i class="iconfont icon-fanhui"></i></a></div> -->
                <div class="center"><span>登录</span></div>
                <div class="right"></div>
            </div>
        </div>

        <div class="page-content">

            <div class="me-login row">
                <div class="col-80">
                    <form name="form" action="" id="form" method="post" >
                        <div class="row b">
                            <i class="iconfont icon-shouji"></i>
                            <input type="number" name="tel" placeholder="请输入手机号" />
                        </div>
                        <div class="row b">
                            <i class="iconfont icon-mima"></i>
                            <input type="password" name="password" placeholder="请输入密码" />
                        </div>
                        <!-- <p class="zy"><a href="{:url('forgot_password')}" class="external" style="color: #666;">忘记密码？</a></p> -->
                        <p class="row segmented-round">
                            <button onclick="" class="col button button-big button-fill" style="background:#66ba61;">登录</button>
                        </p>
                        <p class="bt"><a href="/register" class="external">没有帐号？<span>立即注册</span></a></p>
                    </form>
                </div>
            </div>

        </div>


    </div>
</div>
{/block}

{block name="js"}
<script type="text/javascript">
    var ajaxOn = false ;
    $().ready(function () {
        $("#form").validate({
            rules: {
                tel:{
                    required : true ,
                    digits:true ,
                    min :10000000000,
                    maxlength : 11 ,
                    minlength : 11
                },
                password: "required"
            },
            messages: {
                tel: {
                    required : "请输入手机号" ,
                    digits:"请输入正确的手机号" ,
                    min : "请输入正确的手机号" ,
                    maxlength : "请输入正确的手机号" ,
                    minlength : "请输入正确的手机号"
                },
                password: '请输入密码'
            },
            showErrors: function (errorMap, errorList) {
                $.each(errorList, function (i, v) {
                    messageToast( v.message );
                    return false;
                });
            },
            onfocusout: false,
            onsubmit : true ,
            onkeyup : false ,
            onclick : false ,
            focusInvalid:false,
            submitHandler:function(){
                if (ajaxOn) {
                    return false ;
                }
                ajaxOn = true ;
                $.post("{:url('login')}", $("#form").serialize(), function(data){
                    messageToast( data.info );
                    if (data.status == 'y') {
                        location.href='/index'
                    }
                    ajaxOn = false ;
                }, 'json');

                return false ;
            }
        });
    });
</script>
{/block}